#include <algorithm>
#include <iostream>

using namespace std;
typedef pair<int, int> pi;
const int N = 2e5 + 10;
int a[N];
int n;
int result = 0;

void merge_sort(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) / 2;
  merge_sort(l, mid);
  merge_sort(mid + 1, r);
  int temp[r - l + 1];
  int i = l;
  int j = mid + 1;
  int k = 0;
  while (i <= mid && j <= r) {
    if (a[i] >= a[j]) {
      temp[k++] = a[i++];
    } else {
      temp[k++] = a[j++];
      result += (mid - i + 1);
    }
  }
  while (i <= mid) {
    temp[k++] = a[i++];
  }
  while (j <= r) {
    temp[k++] = a[j++];
  }
  for (int i = l, j = 0; i <= r; i++, j++) {
    a[i] = temp[j];
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    a[i] -= b;
  }

  merge_sort(0, n - 1);
  cout << result << endl;
  return 0;
}
